#ifndef _I2C_H_
#define _I2C_H_
#include "system.h"
typedef void(* pI2cInit)(void);
typedef void (*pI2cDeinit)(void);
typedef void (*pI2cSdaOut)(void);
typedef void (*pI2cSdaIn)(void);
typedef void(* pI2cStart)(void);
typedef void (*pI2cStop)(void);
typedef void (*pI2csendAck)(void);
typedef void(* pI2csendNack)(void);
typedef u8 (* pI2cWaitAck)(void);
typedef u8 (*pI2cReciveByte)(u8);
typedef void (*pI2cSendByte)(char);

typedef struct 
{
    pI2cInit       Pi2cInit;
    pI2cDeinit     Pi2cDeinit; 
    pI2cSdaOut     Pi2cSdaOut;
    pI2cSdaIn      Pi2cSdaIn;
    pI2cStart      Pi2cStart;
    pI2cStop       Pi2cStop;
    pI2csendAck    Pi2csendAck;
    pI2csendNack   Pi2csendNack;
    pI2cWaitAck    Pi2cWaitAck;
    pI2cReciveByte Pi2cReciveByte;
    pI2cSendByte   Pi2cSendByte ;  
}i2c_t;

#define I2C_SCL GPIO_Pin_8
#define I2C_SDA GPIO_Pin_9
#define GPIO_I2C GPIOB

#define I2C_SCL_H GPIO_SetBits(GPIO_I2C,I2C_SCL)
#define I2C_SCL_L GPIO_ResetBits(GPIO_I2C, I2C_SCL)

#define I2C_SDA_H GPIO_SetBits(GPIO_I2C, I2C_SDA)
#define I2C_SDA_L GPIO_ResetBits(GPIO_I2C, I2C_SDA)
#if ELECT
void myI2cDeinit(void);
void myI2cInit(void);
void sdaOut(void);
void sdaIn(void);
void start(void);
void stop(void);
void sendAck(void);
void sendNack(void);
u8 waitAck(void);
void sendByte(char Byte);
u8 recievedByte(u8 ack);
#endif
i2c_t *i2CCreate(void);
#endif
